<template>
  <img :src="imgSrc" alt="文件" />
</template>

<script>
import { download } from '@/utils/request'

export default {
  name: 'FileImg',
  props: {
    fileId: { type: String, required: true }
  },
  data() {
    return { imgSrc: '' }
  },
  watch: {
    fileId: {
      immediate: true,
      handler(val) {
        if (!val) {
          this.imgSrc = ''
          return
        }

        download(val,true).then(res => {
          this.imgSrc = res
        })
      }
    }
  }
}
</script>

